Skip to content

Scribble Assignment#21

Open
varun-martha wants to merge 44 commits into
everest-engineering:mainfrom
varun-martha:scribble-lab
Open

Scribble Assignment#21
varun-martha wants to merge 44 commits into
everest-engineering:mainfrom
varun-martha:scribble-lab

Conversation

@varun-martha
Copy link
Copy Markdown

@varun-martha varun-martha commented May 30, 2026

Summary

This PR completes the core implementation of the Scribble multiplayer drawing game, delivering a fully playable end-to-end game loop. The implementation strictly relies on HTTP polling (no WebSockets) and an in-memory state architecture across the Express backend and React frontend.

1. Room Setup & Lobby

  • Room Generation & Validation: Users can now create rooms with automatically generated, unique 6-character room codes. Payload validation is strictly enforced using Zod.
  • Lobby Synchronization: Implemented the Lobby React component which utilizes HTTP polling to continuously sync the player list and room state in real-time.
  • Rules Enforcement: Enforced strict rules prohibiting duplicate usernames within a room and capped the maximum number of players per room.
  • Memory Management: Added a backend cleanup routine to automatically detect and purge idle or abandoned rooms, ensuring a minimal memory footprint.

2. Game Start & Drawer Selection Flow

  • State Transitions: Added API endpoints and state actions to seamlessly transition rooms from the lobby phase to the playing phase.
  • Drawer Mechanics: The backend now automatically and randomly assigns the "drawer" role to a player when the game starts.
  • Word Selection UI: Built a dedicated UI for the assigned drawer to select from a randomized list of words before the drawing phase begins.
  • Synchronized Timer: Introduced a centralized, server-authoritative round timer that the frontend UI polls to keep all players perfectly synced.

3. Gameplay Interaction (Drawing & Guessing)

  • Real-time Canvas Sync: Implemented interactive drawing on an HTML Canvas. Strokes are batched and sent to the backend, which are then fetched by guessers via high-frequency polling.
  • Guessing System: Non-drawers have a UI to submit chat guesses. The backend performs case-insensitive validation against the selected word.
  • Rate Limiting: Added strict rate limiters on guess submissions to prevent users from spam-guessing or overwhelming the server.
  • Dynamic Scoring: Implemented a comprehensive scoring algorithm. Guessers receive points based on how quickly they guess the word, while the drawer receives points proportional to the number of players who guessed correctly.

4. Game End, Results & Restart

  • Results Phase: The game now automatically halts and transitions to a results screen either when the round timer expires or when all non-drawing players have correctly guessed the word.
  • Leaderboard UI: Developed a ResultScreen component that displays the final word, highlights who successfully guessed it, and ranks players by their total accumulated score.
  • Host Controls & Reset: The room host has the ability to trigger a game reset from the results screen. This instantly transitions the room and all currently connected players back to the lobby state, ready for another round under the same room code.
  • Host Migration: Implemented fallback logic to automatically reassign the host privileges to another active player if the original host disconnects.

Contributor

- Allows the host to initiate the game from the lobby
- Securely assigns a random drawer and provides secret word options
- Implements payload sanitization to hide secret words from guessers
@varun-martha varun-martha changed the title Scribble Assignment - Varun Scribble Assignment May 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant